home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BBS in a Box 7
/
BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso
/
Files
/
Prog
/
T
/
TC Prog Guide.cpt
/
picture ƒ
/
atring.c
< prev
next >
Wrap
Text File
|
1990-11-09
|
2KB
|
93 lines
/*
* FILE: atring.c
* AUTHOR: R. Gonzalez
* CREATED: November 9, 1990
*
* defines methods for atomic ring animated segment
*/
# include "atring.h"
# include "trans.h"
# include "cube.h"
# define NUM_SATELLITES 2
# define RADIUS 2.
# define SATELLITE_TYPE Fast_Cube
# define ANIMATED_SATELLITES FALSE
# define ANGULAR_VELOCITY -PI/10.
/******************************************************************
* initialize
******************************************************************/
boolean Atomic_Ring::init(void)
{
int i;
Translation *transl;
Scaling *scale;
Rotation_Z *roty;
Transformation *combination1,
*combination2;
/* The following temps are needed due to a bug in Think C when
handling arrays of pointers, when the array is an instance var.
*/
Segment *temp_seg;
Transformation *temp_trans;
Animated_Segment::init();
transl = new(Translation);
transl->init();
transl->set(RADIUS-.5,-.5,-.5);
scale = new(Scaling);
scale->init();
scale->set(.2,.2,.2);
roty = new(Rotation_Z);
roty->init();
combination1 = new(Transformation);
combination1->init();
combination2 = new(Transformation);
combination2->init();
num_segments = NUM_SATELLITES;
for (i=0 ; i<NUM_SATELLITES ; i++)
{
temp_seg = new(SATELLITE_TYPE);
segment[i] = temp_seg;
segment[i]->init();
roty->set(i*2.*PI/NUM_SATELLITES);
combination1->combine(transl,roty);
combination2->combine(combination1,scale);
segment[i]->move(combination2);
temp_trans = new(Rotation_Z);
animation[i] = temp_trans;
animation[i]->init();
((Rotation_Z*) animation[i])->set(ANGULAR_VELOCITY);
if (ANIMATED_SATELLITES)
log_animated_segment(segment[i]);
}
temp_seg = new(Fast_Cube);
segment[i=num_segments++] = temp_seg;
segment[i]->init();
transl->set(-.5,-.5,-.5);
segment[i]->move(transl);
temp_trans = new(Transformation);
animation[i] = temp_trans;
animation[i]->init();
transl->destroy();
delete(transl);
scale->destroy();
delete(scale);
roty->destroy();
delete(roty);
combination1->destroy();
delete(combination1);
combination2->destroy();
delete(combination2);
return TRUE;
}